/**
 * 主题初始化脚本组件
 * 用于在页面渲染前设置正确的主题，避免主题闪烁问题
 */
export function ThemeScript() {
    return (
        <script
            dangerouslySetInnerHTML={{
                __html: `
                    (function() {
                        try {
                            const theme = localStorage.getItem('theme') || 'dark';
                            const root = document.documentElement;
                            root.classList.remove('light', 'dark');
                            root.classList.add(theme);
                        } catch (e) {
                            document.documentElement.classList.add('dark');
                        }
                    })();
                `,
            }}
        />
    );
}
